<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
    <link href="../css/element.css" rel="stylesheet"/>
    <link href="../css/swiper.min.css" rel="stylesheet"/>
    <link href="../css/styleindex.css" rel="stylesheet"/>
    <style>
    .el-tabs__item.is-active{
      color: #058142;
    }.el-tabs__active-bar{
      background-color: #058142;
    }.el-tabs{
      background-color: #fff;
    }.el-input__inner{
      border: 0;
      font-size: 1rem;
      text-align: center;
    }.el-input__prefix{
      display: none;
    }.el-tabs__item{
      padding: 0 5px;
    }.layui-laydate{
      width: 100%!important;
    }.layui-laydate-main{
      width: 100%!important;
    }
    .layui-laydate-content table{
      width: 100%!important;
    }.el-table .cell{
      white-space:pre-line;
      text-align: center;
    }
    </style>
</head>
<body style="background:#EFF0F4;">

  <div class="mui-content">
    <div id="vm" class="x-examok" v-cloak>
      <div class="x-header-g" id="header">
        <a class="x-header-arrow" @click="api.closeWin()"></a>
        <div class="x-header-t">毛利排行</div>
      </div>
      <!--  -->
      <div class="x-trtali-box" id="calali" style="margin:1rem"></div>
      <!--  -->
      <div class="">
        <el-table :data="tableData">
          <el-table-column label="菜品名称" width="80" fixed>
            <template slot-scope="scope">
              {{scope.row.title}}
            </template>
          </el-table-column>
          <el-table-column :label="'前三个月 \n 毛利'" width="80">
            <template slot-scope="scope">
              {{scope.row.title}}
            </template>
          </el-table-column>
          <el-table-column label="毛利排名" width="80">
            <template slot-scope="scope">
              {{scope.row.title}}
            </template>
          </el-table-column>
          <el-table-column label="毛利率" width="80">
            <template slot-scope="scope">
              {{scope.row.title}}
            </template>
          </el-table-column>
          <el-table-column label="毛利占比" width="80">
            <template slot-scope="scope">
              {{scope.row.title}}
            </template>
          </el-table-column>
          <el-table-column label="累计毛利占比" width="80">
            <template slot-scope="scope">
              {{scope.row.title}}
            </template>
          </el-table-column>
        </el-table>
      </div>
    </div>
  </div>

  <script type="text/javascript" src="../script/vue.js"></script>
  <script type="text/javascript" src="../script/element.js"></script>
  <script type="text/javascript" src="../script/api.js"></script>
  <script type="text/javascript" src="../script/base.js"></script>
  <script type="text/javascript" src="../script/swiper.min.js"></script>
  <script type="text/javascript" src="../script/laydate/laydate.js"></script>
	<script>
apiready = function () {

  $api.fixStatusBar($api.byId('header'));


    //
    var vm = new Vue({
      el:'#vm',
      data(){
        return{
          cardsmonth:'',
          activeName: 'first',
          tableData:[],
          tableDatatwo:[],
          tableDatathird:[],
          tableDatathird1:[],
          tableDatathird2:[],
          tableDatathird3:[],
          tableDatafour:[],
          tableDatafive:[],
          tableDatasix:[],
          desc1:0,
          desc2:0,
          desc3:0,
          desc4:0,
          istype:'0',
          itemKey:'',
          notkey:false,
          onename:'',
          twoname:'',
          thirdname:'',
          fourname:'',
          fivename:'',
          noget:0,
          daynum1:'',
          daynum2:'',
          daynum3:'',
          daynum4:'',
          daynum5:'',
          food1:'',
          food2:'',
          food3:'',
          food4:'',
          food5:'',
          tableDatafive:'',
          onecheckname:'',
          twocheckname:'',
          thirdcheckname:'',
          fourcheckname:'',
          fivecheckname:'',
          curId:0,
          tabsdata:[{
            'title':'效率数据',
            'type':1
          },{
            'title':'营收数据',
            'type':2
          },{
            'title':'堂食数据',
            'type':3
          },{
            'title':'外卖数据',
            'type':4
          },{
            'title':'营销数据',
            'type':5
          },{
            'title':'能源数据',
            'type':6
          }]
        }
      },
      created:function() {
        var that=this;

      },
      mounted:function(){
        var that=this;
        //当前月份
        var date = new Date();
        var year = date.getFullYear();
        var month = date.getMonth()+1;
        var day = date.getDate();
        if(month<10){
          month = '' + 0 + month;
        }
        if(day<10){
          day = '' + 0 + day;
        }
        var toMonth = '' + year + month + day;
        that.cardsmonth = toMonth;
        that.chancedata = toMonth;
        laydate.render({
          elem: '#calali',
          position: 'static',
          btns:['now'],
          format:'yyyyMMdd',
          // theme:'#058142',
          change:function(value,date){
            console.log(value);
            console.log(that.istype);
            that.cardsmonth = value;
            that.chancedata = value;
            that.toajax()
          }
        });
        that.getdatafirst('1')

      },
      methods: {
        //
        toajax:function(){
          var that = this;
          if(that.istype=='0'){
            that.getdatafirst('1')
          }else if(that.istype=='1'){
            that.getdatafirst('2')
          }else if(that.istype=='2'){
            that.getdatafirst('3')
          }else if(that.istype=='3'){
            that.getdatafirst('4')
          }else if(that.istype=='4'){
            that.getdatafirst('5')
          }else if(that.istype=='5'){
            that.getdatafirst('6')
          }
        },
        //data
        getdatafirst:function(label){
          let that=this;
          // console.log(label);
          api.ajax({
            url:baseurl+'api/mgt/analyseDay',
            methods:'get',
            data:{
              values:{
                sec: $api.getStorage('apptoken'),
                date:that.chancedata,
                label:label,
                _ssid:$api.getStorage('jobid')
              }
            }
          },function(ret,err){
            if(ret){
              api.hideProgress();
              console.log(JSON.stringify(ret));
              if(ret.status == 1){
                // that.tableData = ret.data.list;
                that.$nextTick(function(){
                  var mySwiper = new Swiper('.swiper-container',{
                    freeMode: true,
                    loop:false,//设置 active slide 居中后，会有左右留白现象，添加此会让未尾的导航补齐前后空白
                    slideToClickedSlide: false,//设置为true则点击slide会过渡到这个slide。
                    slidesPerView: 4.5,
                    centeredSlides: false,//设定为true时，active slide会居中，而不是默认状态下的居左。
                    spaceBetween: 5,//slide之间设置距离
                    slidesOffsetBefore: 0,//设定slide与左边框的预设偏移量
                    slidesOffsetAfter: 0,//设定slide与右边框的预设偏移量

                  });

                });
              }else{
                api.toast({
                    msg: ret.msg,
                    duration: 3000,
                    location: 'bottom'
                });
              }
            }else{
              api.hideProgress();
              console.log(JSON.stringify(err));
              api.toast({
                  msg: err.msg,
                  duration: 3000,
                  location: 'bottom'
              });
            }
          })
        },
      }
    })
	}


	</script>
</body>
</html>
